package com.work.util;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;


public class ReleaseCalendar {

	public static void readFile() throws IOException {
		
		File excel =  new File ("D:/eclipse_jee/workspace/01. Release Calendar 2014.xls");
        FileInputStream fis = new FileInputStream(excel);
        HSSFWorkbook wb = new HSSFWorkbook(fis);
        HSSFSheet ws = wb.getSheet("Content");
        
        int rowNum = ws.getLastRowNum() + 1;
        int colNum = ws.getRow(0).getLastCellNum();
        for(int i = 0; i < rowNum; i++) {
            HSSFRow row = ws.getRow(i);
            for (int j = 0; j < colNum; j++) {
                HSSFCell cell = row.getCell(j);
                if (null != cell) {
	                String value = cell.toString();
	                if (StringUtils.isNotEmpty(value) ) {         
	                	value.trim();
	                	if (value.contains("Freeze") && !value.contains("Scope")) {
	                		String freezeDate = value.substring(value.indexOf("Freeze") + 9, value.length()-1);	                	
	                		System.out.println("freezeDate = " + freezeDate);
	                	}
	                	if (!"PROD".equals(value) && !"CAB".equals(value) && StringUtils.isNotEmpty(value) && (value.length() == 3 || value.length() == 4) && StringUtils.isNotEmpty(ReleasePhasesEnum.valueOf(value.substring(0,3)).getPhase())){
	                		System.out.println("Release Phase= " + value);
	                	}
	                }	                	                
                }
            }
            System.out.println();
        }        
	}
	
}
